<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>床位调整</title>
<script type="text/javascript" src="static/easyui/jquery.min.js"></script>
<script type="text/javascript" src="static/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="static/easyui/locale/easyui-lang-zh_CN.js"></script>
<link rel="stylesheet" href="static/easyui/themes/icon.css">
<link rel="stylesheet" href="static/easyui/themes/ui-cupertino/easyui.css">
</head>
<body>
		<script type="text/javascript">
		/*  弹出框重置 */
		   $(function(){
			   $("#reset").click(function(){
					$("#cw_added").form("reset");
				});
			   $("#bed_ejection").click(function(){
				   $("#cw_popup").window("open");
			   });
			   /* 回显床位更改完成的病人信息 */
			   $('#bed_replacement').datagrid({
					url:'cw_change',
					columns:[[
						{field:'WH_SICK_ID',title:'住院号',width:200,fixed:false},
						{field:'WH_SICK_NAME',title:'病人姓名',width:200,fixed:false},
						{field:'WH_CHANGE_HAO',title:'原来床位',width:200,fixed:false},
						{field:'DEPARTMENT_NAME',title:'病人科室',width:200,fixed:false},
						{field:'WH_BED_ID',title:'现在床位',width:200,fixed:false},
						{field:'WH_CHANGE_TIME',title:'修改时间',width:200,
							formatter : function(value){
								var d = new Date(value);
								var times=d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate() + ' ' + d.getHours() + ':' + d.getMinutes() + ':' + d.getSeconds();
								return times;
							}, fixed:false},
						{field:'WH_CHANGE_NAME',title:'修改人',width:200,fixed:false}
						
				    ]],
				});
			   /*选择病人基本信息*/
			   $('#cw_patient').datagrid({
					url:'patient_information',
					columns:[[
						{field:'M_EDICALCARD_ID',title:'医疗卡id',width:100,fixed:false,checkbox:true},
						{field:'WH_SICK_ID',title:'住院号',width:200,fixed:false},
						{field:'WH_SICK_NAME',title:'病人姓名',width:200,fixed:false},
						{field:'DEPARTMENT_NAME',title:'科室',width:200,fixed:false}
				    ]],
				});
			  /*模糊查询病人信息*/
			    $('#cw_br_name').searchbox({
			        searcher:function(value,name){
			        	$('#cw_patient').datagrid({
						    url:'fuzzy_patient',
						    queryParams: {
						    whSickName: value,
							},
							columns:[[
								{field:'M_EDICALCARD_ID',title:'医疗卡id',width:100,fixed:false,checkbox:true},
								{field:'WH_SICK_ID',title:'住院号',width:200,fixed:false},
								{field:'WH_SICK_NAME',title:'病人姓名',width:200,fixed:false},
								{field:'DEPARTMENT_NAME',title:'科室',width:200,fixed:false}
								]],
			        	});
			        }
			    });
			  
			    /* 通过按钮把选中的值传到另外一个页面 */
				$("#bed_confirmation").click(function(){
				    var rows = $("#cw_patient").datagrid("getSelections");
				    if(rows.length>1){
				    	$.messager.alert("温馨提示","一次只能选择一个病人");
				    }else if(rows.length==0){
				    	$.messager.alert("温馨提示","你没有选择病人");
					}else{
				    	var row = $("#cw_patient").datagrid("getSelected");
				    	$("#cw_added").form("load",row);
				    	$("#cw_popup").window("close");
				    	 var id=row.DEPARTMENT_ID; 
						$("#gg_id").combobox({
							url:'select-chuangwei?id='+id,
							valueField:'WH_BED_ID',
							textField:'WH_BED_ID'
						});
						
				    }
				 });
			    
			  /*床位修改完成的病人新增到数据库 */
				$("#bed_modification").click(function(){
					 $("#cw_added").form({
							url:'save_modification',
							method:'post',
							onSubmit:function(){
							},
							success:function(){
								//提交成功关闭窗口
								$.messager.alert("温馨提示","床位修改成功");
								$("#bed_replacement").datagrid("reload");
								$("#cw_added").form("clear");
							}
						});
					 	
						$("#cw_added").submit();
						
				});
			  
		   });
		</script>
		<div class="easyui-layout" style="width:600;height:50px;">
			<div data-options="region:'north'" style="height: 45px; padding: 6px;border-top: none;border-left: none;border-right: none;text-align:center;">
					<a id="bed_modification" href="#" class="easyui-linkbutton"
						data-options="iconCls:'icon-add',plain:true" style="width: 80px">新建</a>
					<a id="reset" href="#" class="easyui-linkbutton"
						data-options="iconCls:'icon-reload',plain:true" style="width: 80px">重置</a>
					<a id="drug-init" href="#" class="easyui-linkbutton"
						data-options="iconCls:'icon-print',plain:true" style="width: 80px">处理</a>
			</div>
		</div>
		<div id="wh_cw" class="easyui-layout" style="width:600;height:200px; padding:10px;">
			<form action="" id="cw_added" method="post">
				<table id="bed-table" width="100%">
					<tr height="30px">
						<td>
							<input name="WH_SICK_ID" id="cw_adjustment_id" class="easyui-textbox" readonly="readonly" required="required"
									data-options="label:'住院号：',width:260,labelAlign:'right'">
							<a id="bed_ejection" href="#" class="easyui-linkbutton"
									data-options="iconCls:'icon-search',plain:true" style="width: 40px"></a>
							
						</td>
						
						<td>
							<input name="WH_SICK_NAME" id="cw_adjustment_xz" class="easyui-textbox" readonly="readonly" required="required"
							data-options="label:'病人姓名：',width:260,labelAlign:'right'">
						</td>
				
						<td>
							<select id="cw_ks" name="DEPARTMENT_NAME" class="easyui-combobox" readonly="readonly" 
							data-options="label:'科室：',width:260,labelAlign:'right',editable:false">
							
							</select>
						</td>
					</tr>
							
							
					<tr height="80px">
						<td>
							<select name="WH_BED_ID" id="cw_id"  class="easyui-combobox"  readonly="readonly"
							data-options="label:'当前床位：',width:260,labelAlign:'right',editable:false">
							
							</select>
						</td>
						<td height="30px">
							<input name="cw_tz_time" class="easyui-datetimebox" id="cw_adjustment_time" required="required"
							data-options="label:'调整时间：',width:260,labelAlign:'right',editable:false" value="new Date()">
						</td>
						<td height="30px">
							<input name="cw_kong" id="gg_id" class="easyui-combobox"  required="required"
							data-options="label:'更改床位：',width:260,textField:'WH_BED_ID',valueField:'WH_BED_ID',url:'select-chuangwei',labelAlign:'right',editable:false">
						</td>
					</tr>
					<tr>
						<td>
							<input name="cw_tz_doctor" id="cw_adjustment_doctor" class="easyui-textbox" value=${user.usersName}
							data-options="label:'调整人：',width:260,labelAlign:'right'">
						</td>
					</tr>
				</table>
			</form>
		</div>
		<!-- 显示 所有床位的病人-->
		<div id="tt" class="easyui-layout">
			<table  id="bed_replacement" class="easyui-datagrid" style="height:260px"
			    		data-options="fitColumns:true,pagination:true,pageNumber:1,pageSize:5,pageList:[5]">
			   
			</table>
		</div>
		
		<!-- 病人选择弹出层 -->
		<div id="cw_popup" class="easyui-window" title="病人选择" style="width:650px;height:500px;"
				data-options="iconCls:'icon-save',modal:true,closed:true">
			
			<div class="easyui-layout" style="width:600;height:50px;background-color:#C8F7F7;padding:16px;">
				<a id="bed_confirmation" href="#" class="easyui-linkbutton"
						data-options="iconCls:'icon-add',plain:true" style="width: 80px,background-color:#D6FEFD;">确认</a>
				<input name="lj_check_Id" id="cw_br_name" class="easyui-textbox"
				data-options="label:'病人搜索：',prompt:'请输入病人姓名',width:220,labelAlign:'right'">
			</div>
			<div class="easyui-layout" style="width:600;height:450px;">
				<table  id="cw_patient" class="easyui-datagrid" style="height:400px;"
			    	data-options="fitColumns:true,pagination:true,pageNumber:1,pageSize:5,pageList:[5]">
			   
				</table>
		</div>
		</div>
</body>
</html>